#include <stdio.h>

#define RATE1  0.15
#define RATE2  0.20
#define RATE3  0.25

#define BREAK1  300     //一级工资界点
#define BREAK2  450     //二级工资界点

#define BASE1  (BREAK1 * RATE1)
#define BASE2  BASE1 + (BREAK2 - BREAK1) * RATE2

#define BASETIME 40

#define SELECT_LEN 4

double salarys[] = {8.75, 9.33, 10.00, 11.20};

int main(void)
{
    double salary, sum, worktime, tax;
    int select, i;

    puts("Enter the number of corresponding to the desired pay rate or action:");
    for (i=0; i<SELECT_LEN; ++i) {
        printf("%d) $%.2lf/hr\t\t%c",
                i+1,
                salarys[i],
                (i+1)%2 == 0 ? '\n': ' '
                );
    }

    printf("%d) quit\n", i+1);

    select = i+1;
    while (scanf("%d", &select) == 1) {
        if (select <= i+1 && select > 0)
            break;

        printf("Please enter currect code!\n");
    }

    if (select == i+1) {
        return 0;
    }

    salary = salarys[select-1];
    printf("your are salary is $%.2lf\n", salary);

    printf("please enter a time of one working week !\n");
    scanf("%lf", &worktime);

    if (worktime > BASETIME) {
        worktime = BASETIME+ (worktime - BASETIME) * 1.5;
    }

    sum = worktime * salary;

    if (sum <= BREAK1) {
        tax = sum * RATE1;

    } else if (sum <= BREAK2) {
        tax = BASE1 + (sum - BREAK1) * RATE2;

    } else {
        tax = BASE2 + (sum - BREAK2) * RATE3;
    }

    printf("your are salary:$%.2lf, tax:$%.2lf, net income:$%.2lf\n", sum, tax, sum-tax);

    return 0;
}
